package com.xx.hdfsFx.promptStage;

import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import static com.xx.util.Util.getResourceUrl;

public class ChangePathPrompt {

    public final Button button;
    private final PromptPaneTool promptPaneTool;
    public final TextField textField;

    public ChangePathPrompt(String oldPath, String newPath) {
        promptPaneTool = new PromptPaneTool();
        promptPaneTool.addTitle("移动");
        promptPaneTool.addInfo("移动 : ", oldPath);
        promptPaneTool.addErrorInfo("未找到目标目录");
        textField = promptPaneTool.addInput("到目录 : ", newPath, pathChoice());
        textField.setPrefSize(240, 25);
        button = promptPaneTool.addButton("重构", "取消");
        promptPaneTool.initStage(830, 400);
    }

    private Label pathChoice() {
        Label label = new Label();
        ImageView iv = new ImageView(new Image(getResourceUrl("/texture/cut.png")));
        iv.setPreserveRatio(true);
        iv.setFitWidth(30);
        label.setGraphic(iv);
        label.setOnMouseEntered(event -> label.setStyle("-fx-background-color: #ccffffff"));
        label.setOnMouseExited(event -> label.setStyle("-fx-background-color: null"));
        label.setOnMouseClicked(event -> System.out.println(2));
        return label;
    }

    public void showStage() {
        promptPaneTool.nowStage.show();
    }

    public void closeStage() {
        promptPaneTool.nowStage.close();
    }
}
